﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace ControlerLib
{
    /// <summary>
    /// Interaction logic for SelectHw.xaml
    /// </summary>
    public partial class SelectHw : UserControl
    {
        public delegate void OnHWSelectedHandler(object sender, EventArgs e);
        public event OnHWSelectedHandler OnHWSelected;

        public string hw_name;

        public SelectHw()
        {
            InitializeComponent();
            Popolate_combox(@"hardware settings\swisstom\available.txt");
        }


        private void Popolate_combox(string path)
        {
            
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file =
               new System.IO.StreamReader(path);
            while ((line = file.ReadLine()) != null)
            {
                comboBox_hwname.Items.Add(line);
            }

            file.Close();

            if (comboBox_hwname.Items.Count > 0)
            {
                comboBox_hwname.SelectedIndex = 0;
            }
        }
        private void button_ok_Click(object sender, RoutedEventArgs e)
        {
            hw_name = comboBox_hwname.Items[comboBox_hwname.SelectedIndex].ToString();
            if (OnHWSelected != null)
                OnHWSelected(null, e);
        }

    }
}
